import httpconnect.Moth;

import java.io.*;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

/**
 * Created by zy on 2018/8/16.
 */
public class Main {
    List<Object> a = new ArrayList<>();
    List<Object> b = new ArrayList<>();
    List<Object> c = new ArrayList<>();

    public static void main(String a[]) throws IOException {
        Arrays.asList("abc", "123", "xzy", "opq", "ijk", "lmn").forEach(new Consumer<String>() {
            @Override
            public void accept(String value) {

            }
        });
        Arrays.asList("abc", "123", "xzy", "opq", "ijk", "lmn").forEach(new Consumer<String>() {
            @Override
            public void accept(String value) {

            }
        });
        Arrays.asList("abc", "123", "xzy", "opq", "ijk", "lmn").forEach(value -> {

        });
        Arrays.asList("abc", "123", "xzy", "opq", "ijk", "lmn").forEach(value -> {

        });
        final Moth Math = new Moth();
        String[] cmd = {"cmd", "/c", "echo abc"};
        //Process exec = Runtime.getRuntime().exec(cmd);
        //OutputStream outputStream = exec.getOutputStream();
        //InputStream inputStream = exec.getInputStream();

        String s = "，，。\n" +
                "？，，。，。\n" +
                "、，，，！\n" +
                "“”，，，。“量”，，但在“质”。，。\n" +
                "，。\n" +
                "，，？\n" +
                "？，。\n" +
                "“”，，，，，、。\n" +
                "，，“”，。";
        for (int i = 0; i < s.toCharArray().length; i++) {
            System.out.print((int) s.toCharArray()[i] + "==");
        }
        double i1 = Math.random();
    }

    public static void mains(String arg[]) throws Exception {
        Object[] init_arr = {"adv", 2, 33, 4, 5, 6, "32", 7, 8, 9, "java", 140, 11, 152, 13, 14, 15, 16};
        System.out.println();
        long f = System.currentTimeMillis();
        StringBuffer na = new StringBuffer();
        //String na = "";
        for (int i = 0; i < 50; i++) {
            na.append(i);
            //na+= i;
        }//21（78） 11（98） 16（88）3 4 5 7
        System.out.println(na.length());
        System.out.println(na.toString());
        na.delete(6, na.length() - 6);
        na.append(true);
        System.out.println(System.currentTimeMillis() - f);
        System.out.println(na.toString());
        //System.out.println("abc\tabc");
        System.out.println("*******");
        Main main = new Main();
        String one = "java";
        String two = "java";
        int i = 80;
        while (true) {
            i++;
            Thread.sleep(1000);
            if (i % 20 == 0) {
                System.out.println();
            }
            System.out.print(String.format("%03d", i) + "->");
            if (i > 999) {
                break;
            }
        }
//        main.function(init_arr, 0, init_arr.length - 1);
//        main.merge();
        //nine();
        //System.out.println(one.hashCode());
        //System.out.println(two.hashCode());
        //System.out.println(Integer.toHexString(System.identityHashCode(one)));
        //System.out.println(Integer.toHexString(System.identityHashCode(two)));
        System.out.println(((char) 1164) + " *******");
        //System.out.println(PoiUtil.getHtml(new File("D:/0612.docx"),"m2.docx","D:/"));
    }

    public List getA() {
        return a;
    }

    void merge() {
        List<Object> list = new ArrayList<>();
        list.addAll(a);
        list.addAll(b);
        list.addAll(c);
        System.out.print(list);
    }

    void function(Object[] arr, int start, int end) {
        if (end - start <= 0) {
            c.add(arr[end]);
            return;
        }
        if (end - start == 1) {
            if ((int) (Math.random() * 2) == 1) {
                a.add(arr[end]);
                b.add(arr[start]);
            } else {
                b.add(arr[end]);
                a.add(arr[start]);
            }
            return;
        }

        int temp = end - start;
        int temp2 = 0;
        if (temp % 2 == 0) {
            temp2 = temp / 2;
        } else {
            temp2 = Math.round(temp / 2);
        }
        function(arr, start, temp2 + start);
        function(arr, start + temp2 + 1, end);
    }
}

class abc {
    public static void main(String[] args) {
        String url = "http://www.baidu.com";
        for (String string : ShortText(url)) {
            print(string);
        }
    }
    public static String[] ShortText(String string) {
        String key = "Geek";                 //自己定义生成MD5加密字符串前的混合KEY
        String[] chars = new String[]{          //要使用生成URL的字符
                "a", "b", "c", "d", "e", "f", "g", "h",
                "i", "j", "k", "l", "m", "n", "o", "p",
                "q", "r", "s", "t", "u", "v", "w", "x",
                "y", "z", "0", "1", "2", "3", "4", "5",
                "6", "7", "8", "9", "A", "B", "C", "D",
                "E", "F", "G", "H", "I", "J", "K", "L",
                "M", "N", "O", "P", "Q", "R", "S", "T",
                "U", "V", "W", "X", "Y", "Z"
        };
        String hex = MD5encry.MD5Encode(key + string);
        int hexLen = hex.length();
        int subHexLen = hexLen / 8;
        String[] ShortStr = new String[4];
        for (int i = 0; i < subHexLen; i++) {
            String outChars = "";
            int j = i + 1;
            String subHex = hex.substring(i * 8, j * 8);
            long idx = Long.valueOf("3FFFFFFF", 16) & Long.valueOf(subHex, 16);

            for (int k = 0; k < 6; k++) {
                int index = (int) (Long.valueOf("0000003D", 16) & idx);
                outChars += chars[index];
                idx = idx >> 5;
            }
            ShortStr[i] = outChars;
        }
        return ShortStr;
    }
    private static void print(Object messagr) {
        System.out.println(messagr);
    }
}

class MD5encry {
    private final static String[] hexDigits = {
            "0", "1", "2", "3", "4", "5", "6", "7",
            "8", "9", "a", "b", "c", "d", "e", "f"};

    public static String byteArrayToHexString(byte[] b) {
        StringBuffer resultSb = new StringBuffer();
        for (int i = 0; i < b.length; i++) {
            resultSb.append(byteToHexString(b[i]));
        }
        return resultSb.toString();
    }

    private static String byteToHexString(byte b) {
        int n = b;
        if (n < 0)
            n = 256 + n;
        int d1 = n / 16;
        int d2 = n % 16;
        return hexDigits[d1] + hexDigits[d2];
    }

    public static String MD5Encode(String origin) {
        String resultString = null;
        try {
            resultString = new String(origin);
            MessageDigest md = MessageDigest.getInstance("MD5");
            resultString.trim();
            resultString = byteArrayToHexString(md.digest(resultString.getBytes("UTF-8")));
        } catch (Exception ex) {
        }
        return resultString;
    }
    public static void main(String[] args) {
        String data = "189022881112011111118:09sz0000123456789987654321";
        System.out.println(MD5Encode(data));
    }
}